home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / term-source.lha / Boxes.c < prev    next >
C/C++ Source or Header  |  1996-10-20  |  13KB  |  742 lines

  1. /*
  2. **    Boxes.c
  3. **
  4. **    Text box management support routines
  5. **
  6. **    Copyright © 1990-1996 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #ifndef _GLOBAL_H
  13. #include "Global.h"
  14. #endif
  15.  
  16.     /* Sizing data. */
  17.  
  18. STATIC struct RastPort    *SZ_RPort;
  19. STATIC struct TextFont    *SZ_TextFont;
  20. STATIC struct Screen    *SZ_Screen;
  21.  
  22. STATIC LONG                 SZ_Left,
  23.                          SZ_Top,
  24.                          SZ_CurrentLeft,
  25.                          SZ_CurrentTop,
  26.                          SZ_CurrentWidth,
  27.                          SZ_MaxWidth,
  28.                          SZ_TextPen,
  29.                          SZ_BackPen,
  30.                          SZ_AverageGlyphWidth;
  31.  
  32.     /* SZ_SetTopEdge(LONG Top):
  33.      *
  34.      *    Set the current object top edge.
  35.      */
  36.  
  37. VOID
  38. SZ_SetTopEdge(LONG Top)
  39. {
  40.     SZ_CurrentTop = Top;
  41. }
  42.  
  43.     /* SZ_SetLeftEdge(LONG Left):
  44.      *
  45.      *    Set the current object left edge.
  46.      */
  47.  
  48. VOID
  49. SZ_SetLeftEdge(LONG Left)
  50. {
  51.     SZ_CurrentLeft = Left;
  52. }
  53.  
  54.     /* SZ_SetAbsoluteTop(LONG Top):
  55.      *
  56.      *    Set new inner window top edge.
  57.      */
  58.  
  59. VOID
  60. SZ_SetAbsoluteTop(LONG Top)
  61. {
  62.     SZ_Top = Top;
  63. }
  64.  
  65.     /* SZ_SetWidth(LONG Width):
  66.      *
  67.      *    Set current object width.
  68.      */
  69.  
  70. VOID
  71. SZ_SetWidth(LONG Width)
  72. {
  73.     SZ_CurrentWidth = Width;
  74. }
  75.  
  76.     /* SZ_AddLeftOffset(LONG Offset):
  77.      *
  78.      *    Update current object left offset.
  79.      */
  80.  
  81. VOID
  82. SZ_AddLeftOffset(LONG Offset)
  83. {
  84.     SZ_CurrentLeft += Offset;
  85. }
  86.  
  87.     /* SZ_LeftOffsetN(LONG DataArray,...):
  88.      *
  89.      *    Determine the maximum length of a number of
  90.      *    gadget labels (first, second, third item, -1 terminates
  91.      *    the array).
  92.      */
  93.  
  94. LONG
  95. SZ_LeftOffsetN(LONG DataArray,...)
  96. {
  97.     LONG    *Data = &DataArray,
  98.              Len,
  99.              Max = 0;
  100.     STRPTR     String;
  101.  
  102.     while(*Data != -1)
  103.     {
  104.         String = LocaleString(*Data++);
  105.  
  106.         if((Len = TextLength(SZ_RPort,String,strlen(String))) > Max)
  107.             Max = Len;
  108.     }
  109.  
  110.     return(Max + INTERWIDTH);
  111. }
  112.  
  113.     /* SZ_SizeCleanup():
  114.      *
  115.      *    Free data allocated by SZ_SizeSetup().
  116.      */
  117.  
  118. VOID
  119. SZ_SizeCleanup()
  120. {
  121.     if(SZ_TextFont)
  122.     {
  123.         CloseFont(SZ_TextFont);
  124.  
  125.         SZ_TextFont = NULL;
  126.     }
  127.  
  128.     FreeVecPooled(SZ_RPort);
  129.     SZ_RPort = NULL;
  130. }
  131.  
  132.     /* SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr):
  133.      *
  134.      *    Perform setups for gadget creation.
  135.      */
  136.  
  137. BOOL
  138. SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr)
  139. {
  140.     SZ_SizeCleanup();
  141.  
  142.     if(Screen)
  143.     {
  144.         struct DrawInfo *DrawInfo;
  145.  
  146.         if(DrawInfo = GetScreenDrawInfo(Screen))
  147.         {
  148.             SZ_TextPen = DrawInfo->dri_Pens[TEXTPEN];
  149.             SZ_BackPen = DrawInfo->dri_Pens[BACKGROUNDPEN];
  150.  
  151.             FreeScreenDrawInfo(Screen,DrawInfo);
  152.         }
  153.     }
  154.     else
  155.     {
  156.         if(!TextAttr)
  157.             return(FALSE);
  158.     }
  159.  
  160.     SZ_Screen = Screen;
  161.  
  162.     if(SZ_RPort = (struct RastPort *)AllocVecPooled(sizeof(struct RastPort),MEMF_ANY | MEMF_CLEAR))
  163.     {
  164.         InitRastPort(SZ_RPort);
  165.  
  166.         if(!TextAttr)
  167.             TextAttr = Screen->Font;
  168.  
  169.         if(SZ_TextFont = SmartOpenDiskFont(TextAttr))
  170.         {
  171.             LONG    i,Width,Counted = 0,NumericWidth = 0;
  172.             UBYTE    Char;
  173.  
  174.             InterWidth = INTERWIDTH;
  175.  
  176.             if(SZ_TextFont->tf_YSize <= 8)
  177.                 InterHeight = 1;
  178.             else
  179.                 InterHeight = SZ_TextFont->tf_YSize / 4;
  180.  
  181.             SetFont(SZ_RPort,SZ_TextFont);
  182.  
  183.             SZ_AverageGlyphWidth = 0;
  184.  
  185.             for(i = 32 ; i < 127 ; i++)
  186.             {
  187.                 Char = i;
  188.  
  189.                 Width = TextLength(SZ_RPort,&Char,1);
  190.  
  191.                     /* For really pathologic fonts... */
  192.  
  193.                 if(Width < 0 || Width > 32767)
  194.                     continue;
  195.  
  196.                 SZ_AverageGlyphWidth += Width;
  197.  
  198.                 Counted++;
  199.             }
  200.  
  201.             for(i = 160 ; i < 256 ; i++)
  202.             {
  203.                 Char = i;
  204.  
  205.                 Width = TextLength(SZ_RPort,&Char,1);
  206.  
  207.                     /* For really pathologic fonts... */
  208.  
  209.                 if(Width < 0 || Width > 32767)
  210.                     continue;
  211.  
  212.                 SZ_AverageGlyphWidth += Width;
  213.  
  214.                 Counted++;
  215.             }
  216.  
  217.             for(i = '0' ; i < '9' ; i++)
  218.             {
  219.                 Char = i;
  220.  
  221.                 Width = TextLength(SZ_RPort,&Char,1);
  222.  
  223.                 if(Width > NumericWidth)
  224.                     NumericWidth = Width;
  225.             }
  226.  
  227.             Char = ' ';
  228.  
  229.             Width = TextLength(SZ_RPort,&Char,1);
  230.  
  231.             if(Width > NumericWidth)
  232.                 NumericWidth = Width;
  233.  
  234.             SZ_AverageGlyphWidth /= Counted;
  235.  
  236.             if(SZ_AverageGlyphWidth < NumericWidth)
  237.                 SZ_AverageGlyphWidth = NumericWidth;
  238.  
  239.             SZ_Left = InterWidth;
  240.  
  241.             if(Screen)
  242.                 SZ_Top = Screen->WBorTop + Screen->Font->ta_YSize + 1 + InterHeight;
  243.             else
  244.                 SZ_Top = 0;
  245.  
  246.             SZ_CurrentLeft    = InterWidth;
  247.             SZ_CurrentTop    = SZ_Top;
  248.  
  249.             SZ_CurrentWidth    = 0;
  250.             SZ_MaxWidth    = 0;
  251.  
  252.             return(TRUE);
  253.         }
  254.     }
  255.  
  256.     SZ_SizeCleanup();
  257.  
  258.     return(FALSE);
  259. }
  260.  
  261.     /* SZ_GetLen(STRPTR String):
  262.      *
  263.      *    Get the string pixel width, measured using the average
  264.      *    glyph width.
  265.      */
  266.  
  267. ULONG
  268. SZ_GetLen(STRPTR String)
  269. {
  270.     return(strlen(String) * SZ_AverageGlyphWidth);
  271. }
  272.  
  273.     /* SZ_FreeBox(struct TextBox *Box):
  274.      *
  275.      *    Free a text box.
  276.      */
  277.  
  278. STATIC VOID
  279. SZ_FreeBox(struct TextBox *Box)
  280. {
  281.     if(Box)
  282.     {
  283.         if(Box->Text)
  284.         {
  285.             LONG i;
  286.  
  287.             for(i = 0 ; i < Box->NumLines ; i++)
  288.             {
  289.                 if(Box->Text[i])
  290.                     FreeVecPooled(Box->Text[i]);
  291.             }
  292.  
  293.             FreeVecPooled(Box->Text);
  294.         }
  295.  
  296.         FreeVecPooled(Box->Title);
  297.  
  298.         FreeVecPooled(Box);
  299.     }
  300. }
  301.  
  302.     /* SZ_FreeBoxes(struct TextBox *FirstBox):
  303.      *
  304.      *    Free a number of text boxes.
  305.      */
  306.  
  307. VOID
  308. SZ_FreeBoxes(struct TextBox *FirstBox)
  309. {
  310.     if(FirstBox)
  311.     {
  312.         struct TextBox *NextBox;
  313.  
  314.         do
  315.         {
  316.             NextBox = FirstBox->NextBox;
  317.  
  318.             SZ_FreeBox(FirstBox);
  319.  
  320.             FirstBox = NextBox;
  321.         }
  322.         while(FirstBox);
  323.     }
  324. }
  325.  
  326.     /* SZ_BoxWidth(LONG Chars):
  327.      *
  328.      *    Determine the width of a text box.
  329.      */
  330.  
  331. LONG
  332. SZ_BoxWidth(LONG Chars)
  333. {
  334.     return((LONG)(4 + SZ_AverageGlyphWidth * Chars + 4));
  335. }
  336.  
  337.     /* SZ_BoxHeight(LONG Lines):
  338.      *
  339.      *    Determine the height of a text box.
  340.      */
  341.  
  342. LONG
  343. SZ_BoxHeight(LONG Lines)
  344. {
  345.     return(2 + SZ_TextFont->tf_YSize * Lines + 2);
  346. }
  347.  
  348.     /* SZ_CreateTextBox(struct TextBox **FirstBox,...):
  349.      *
  350.      *    Create a text box, this routine works similar
  351.      *    to the CreateGadget() frontend.
  352.      */
  353.  
  354. struct TextBox *
  355. SZ_CreateTextBox(struct TextBox **FirstBox,...)
  356. {
  357.     va_list             VarArgs;
  358.     struct TagItem    *TagList,
  359.                     *ThisTag;
  360.     LONG             Chars,Lines,
  361.                      Width,
  362.                      Height,
  363.                      Left = SZ_CurrentLeft;
  364.     BOOL             AutoWidth    = FALSE,
  365.                      MoveDown    = TRUE,
  366.                      SetLeft    = FALSE,
  367.                      SetBelow    = FALSE;
  368.  
  369.     struct TextBox    *Box;
  370.     LONG             i;
  371.  
  372.     va_start(VarArgs,FirstBox);
  373.  
  374.     TagList = (struct TagItem *)VarArgs;
  375.  
  376.     if(ThisTag = FindTagItem(SZ_Lines,TagList))
  377.         Lines = (LONG)ThisTag->ti_Data;
  378.     else
  379.         return(NULL);
  380.  
  381.     Height = 2 + SZ_TextFont->tf_YSize * Lines + 2;
  382.  
  383.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  384.         AutoWidth = ThisTag->ti_Data;
  385.  
  386.     if(!AutoWidth)
  387.         return(NULL);
  388.     else
  389.         Chars = (SZ_CurrentWidth - 8) / SZ_AverageGlyphWidth;
  390.  
  391.     if(!(Box = (struct TextBox *)AllocVecPooled(sizeof(struct TextBox),MEMF_ANY | MEMF_CLEAR)))
  392.         return(NULL);
  393.  
  394.     if(ThisTag = FindTagItem(SZ_NewColumn,TagList))
  395.     {
  396.         if(ThisTag->ti_Data)
  397.         {
  398.             SZ_CurrentTop    = SZ_Top;
  399.             Left            = Left + SZ_MaxWidth + InterWidth;
  400.  
  401.             SZ_MaxWidth    = 0;
  402.         }
  403.     }
  404.  
  405.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  406.         AutoWidth = ThisTag->ti_Data;
  407.  
  408.     if(!AutoWidth)
  409.         Width = SZ_BoxWidth(Chars);
  410.     else
  411.         Width = SZ_CurrentWidth;
  412.  
  413.     Box->Left        = Left;
  414.     Box->Top        = SZ_CurrentTop;
  415.     Box->Width        = Width;
  416.     Box->Height        = Height;
  417.  
  418.     Box->LineWidth    = Chars * SZ_AverageGlyphWidth;
  419.     Box->LineHeight    = SZ_TextFont->tf_YSize;
  420.  
  421.     Box->NumChars    = Chars;
  422.     Box->NumLines    = Lines;
  423.  
  424.     Box->TitleFgPen    = SZ_TextPen;
  425.     Box->TitleBgPen    = SZ_BackPen;
  426.     Box->TextPen    = SZ_TextPen;
  427.  
  428.     if(!(Box->Title = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  429.     {
  430.         SZ_FreeBox(Box);
  431.  
  432.         return(NULL);
  433.     }
  434.  
  435.     if(!(Box->Text = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  436.     {
  437.         SZ_FreeBox(Box);
  438.  
  439.         return(NULL);
  440.     }
  441.  
  442.     for(i = 0 ; i < Lines ; i++)
  443.     {
  444.         if(!(Box->Text[i] = (STRPTR)AllocVecPooled(Chars + 1,MEMF_ANY | MEMF_CLEAR)))
  445.         {
  446.             SZ_FreeBox(Box);
  447.  
  448.             return(NULL);
  449.         }
  450.     }
  451.  
  452.     if(SetBelow)
  453.         MoveDown = FALSE;
  454.  
  455.     if(MoveDown)
  456.         SZ_CurrentTop = SZ_CurrentTop + Height + InterHeight;
  457.     else
  458.         SZ_MaxWidth = 0;
  459.  
  460.     if(Width > SZ_MaxWidth)
  461.         SZ_MaxWidth = Width;
  462.  
  463.     if(!SetLeft)
  464.         SZ_CurrentLeft = Left;
  465.  
  466.     if(!(*FirstBox))
  467.         *FirstBox = Box;
  468.     else
  469.     {
  470.         struct TextBox *CurrentBox = *FirstBox;
  471.  
  472.         while(CurrentBox->NextBox)
  473.             CurrentBox = CurrentBox->NextBox;
  474.  
  475.         CurrentBox->NextBox = Box;
  476.     }
  477.  
  478.     return(Box);
  479. }
  480.  
  481.     /* SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...):
  482.      *
  483.      *    Set the titles displayed in a text box.
  484.      */
  485.  
  486. VOID
  487. SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...)
  488. {
  489.     if(Box)
  490.     {
  491.         STRPTR    *Data = &Array;
  492.         LONG     i = 0;
  493.  
  494.         while(*Data != NULL)
  495.         {
  496.             if(i < Box->NumLines)
  497.                 Box->Title[i++] = *Data;
  498.  
  499.             Data++;
  500.         }
  501.     }
  502. }
  503.  
  504.     /* SZ_SetLine():
  505.      *
  506.      *    Print a string into a text box, plain version.
  507.      */
  508.  
  509. VOID
  510. SZ_SetLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String)
  511. {
  512.     LONG             FgPen    = ReadAPen(RPort),
  513.                      BgPen    = ReadBPen(RPort),
  514.                      DrMd    = ReadDrMd(RPort);
  515.     struct TextFont    *Font    = RPort->Font;
  516.  
  517.     LONG             Width,Len,
  518.                      Left    = Box->Left + 4,
  519.                      Top    = Box->Top + 2 + Line * Box->LineHeight;
  520.  
  521.     SetPens(RPort,Box->TextPen,SZ_BackPen,JAM2);
  522.  
  523.     if(Font != UserTextFont)
  524.         SetFont(RPort,UserTextFont);
  525.  
  526.     if(Len = strlen(String))
  527.     {
  528.         if(Len > Box->NumChars)
  529.             Len = Box->NumChars;
  530.  
  531.         Len = FitText(RPort,Box->LineWidth,String,Len);
  532.  
  533.         if(Len)
  534.         {
  535.             Width = TextLength(RPort,String,Len);
  536.  
  537.             PlaceText(RPort,Left,Top,String,Len);
  538.         }
  539.         else
  540.             Width = 0;
  541.     }
  542.     else
  543.         Width = 0;
  544.  
  545.     if(Width != Box->LineWidth)
  546.     {
  547.         if(FgPen != SZ_BackPen)
  548.         {
  549.             SetAPen(RPort,SZ_BackPen);
  550.  
  551.             RectFill(RPort,Left + Width,Top,Left + Box->LineWidth - 1,Top + Box->LineHeight - 1);
  552.  
  553.             SetAPen(RPort,FgPen);
  554.         }
  555.         else
  556.             RectFill(RPort,Left + Width,Top,Left + Box->LineWidth - 1,Top + Box->LineHeight - 1);
  557.     }
  558.  
  559.     SetPens(RPort,FgPen,BgPen,DrMd);
  560.  
  561.     if(String != Box->Text[Line])
  562.     {
  563.         if(Len > 0)
  564.             CopyMem(String,Box->Text[Line],Len);
  565.  
  566.         Box->Text[Line][Len] = 0;
  567.     }
  568.  
  569.     if(Font != UserTextFont)
  570.         SetFont(RPort,Font);
  571. }
  572.  
  573.     /* SZ_PrintLine():
  574.      *
  575.      *    Print a string into a text box, varargs version.
  576.      */
  577.  
  578. VOID
  579. SZ_PrintLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String,...)
  580. {
  581.     va_list    VarArgs;
  582.     UBYTE    Buffer[256];
  583.  
  584.     va_start(VarArgs,String);
  585.     LimitedVSPrintf(sizeof(Buffer),Buffer,String,VarArgs);
  586.     va_end(VarArgs);
  587.  
  588.     SZ_SetLine(RPort,Box,Line,Buffer);
  589. }
  590.  
  591.     /* SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box):
  592.      *
  593.      *    (Re-)Draw a text box.
  594.      */
  595.  
  596. STATIC VOID
  597. SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box)
  598. {
  599.     if(Box)
  600.     {
  601.         LONG             LineY,i,Len,FgPen = ReadAPen(RPort),BgPen = ReadBPen(RPort),DrMd = ReadDrMd(RPort);
  602.         struct TextFont    *Font = RPort->Font;
  603.  
  604.         if(Font != UserTextFont)
  605.             SetFont(RPort,UserTextFont);
  606.  
  607.         if(FgPen != SZ_BackPen)
  608.         {
  609.             SetAPen(RPort,SZ_BackPen);
  610.  
  611.             FillBox(RPort,Box->Left,Box->Top,Box->Width,Box->Height);
  612.  
  613.             SetAPen(RPort,FgPen);
  614.         }
  615.         else
  616.             FillBox(RPort,Box->Left,Box->Top,Box->Width,Box->Height);
  617.  
  618.         DrawBevelBox(RPort,Box->Left,Box->Top,Box->Width,Box->Height,
  619.             GT_VisualInfo,    VisualInfo,
  620.             GTBB_Recessed,    TRUE,
  621.         TAG_DONE);
  622.  
  623.         LineY = Box->Top + 2;
  624.  
  625.         SetPens(RPort,Box->TitleFgPen,Box->TitleBgPen,JAM2);
  626.  
  627.         for(i = 0 ; i < Box->NumLines ; i++)
  628.         {
  629.             if(Len = strlen(Box->Title[i]))
  630.                 PlaceText(RPort,Box->Left - INTERWIDTH - TextLength(RPort,Box->Title[i],Len),LineY,Box->Title[i],Len);
  631.  
  632.             LineY += Box->LineHeight;
  633.         }
  634.  
  635.         for(i = 0 ; i < Box->NumLines ; i++)
  636.             SZ_PrintLine(RPort,Box,i,Box->Text[i]);
  637.  
  638.         SetPens(RPort,FgPen,BgPen,DrMd);
  639.  
  640.         if(Font != UserTextFont)
  641.             SetFont(RPort,Font);
  642.     }
  643. }
  644.  
  645.     /* SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox):
  646.      *
  647.      *    (Re-)Draw a number of text boxes.
  648.      */
  649.  
  650. VOID
  651. SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox)
  652. {
  653.     do
  654.         SZ_DrawBox(RPort,FirstBox);
  655.     while(FirstBox = FirstBox->NextBox);
  656. }
  657.  
  658.     /* SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top):
  659.      *
  660.      *    Change the location of a text box.
  661.      */
  662.  
  663. STATIC VOID
  664. SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top)
  665. {
  666.     Box->Left    += Left;
  667.     Box->Top    += Top;
  668. }
  669.  
  670.     /* SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  671.      *
  672.      *    Change the locations of a number of text boxes.
  673.      */
  674.  
  675. VOID
  676. SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  677. {
  678.     do
  679.         SZ_MoveBox(FirstBox,Left,Top);
  680.     while(FirstBox = FirstBox->NextBox);
  681. }
  682.  
  683.     /* SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top):
  684.      *
  685.      *    Set the location of a text box.
  686.      */
  687.  
  688. STATIC VOID
  689. SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top)
  690. {
  691.     if(Left >= 0)
  692.         Box->Left = Left;
  693.  
  694.     if(Top >= 0)
  695.         Box->Top = Top;
  696. }
  697.  
  698.     /* SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  699.      *
  700.      *    Set the locations of a number of text boxes.
  701.      */
  702.  
  703. VOID
  704. SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  705. {
  706.     do
  707.         SZ_SetBox(FirstBox,Left,Top);
  708.     while(FirstBox = FirstBox->NextBox);
  709. }
  710.  
  711.     /* SZ_GetBoxInfo(struct TextBox *Box,LONG Type):
  712.      *
  713.      *    Query information on a certain text box.
  714.      */
  715.  
  716. LONG
  717. SZ_GetBoxInfo(struct TextBox *Box,LONG Type)
  718. {
  719.     switch(Type)
  720.     {
  721.         case BOX_LEFT:
  722.  
  723.             return(Box->Left);
  724.  
  725.         case BOX_TOP:
  726.  
  727.             return(Box->Top);
  728.  
  729.         case BOX_WIDTH:
  730.  
  731.             return(Box->Width);
  732.  
  733.         case BOX_HEIGHT:
  734.  
  735.             return(Box->Height);
  736.  
  737.         default:
  738.  
  739.             return(0);
  740.     }
  741. }
  742.